
package com.hsnn.medstgmini.base.std.model;

import java.sql.Timestamp;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import com.hsnn.medstgmini.base.dict.model.DicArea;
import com.hsnn.medstgmini.base.dict.model.DicCompType;


/**
 * 企业库实体类
 * @author hss@njhsnn
 * 2015年6月9日
 */
@Entity
@Table(name="std_compinfo")

public class StdCompinfo  implements java.io.Serializable {


    // Fields    

     /**
	 *
	 */
	private static final long serialVersionUID = -4950423696436774668L;
	 private String compId; //企业Id
     private String compCode;//企业编码
     private String compName;//企业名称
     private String compSpelCode;//企业名称拼音码
     private String compNameEng;//企业英文名称
     private String compShortName;//企业简称
     private String compShortSpelCode;//简称拼音码
     private Short compType;//企业类型 1.生产企业 2.经营配送企业
     private String areaId;//注册地行政区划代码
     private String compRegId;//企业注册类型
     private String orgCode;//组织机构代码
     private String compGroupId;//所属集团ID
     private String compPhone;//机构电话
     private String compAddress;//机构地址
     private Short compClassify;//企业分类 0默认 1药品 2耗材 3药品耗材
     private String compClassifyName;//企业分类名称
     private Short status;//状态 1.启用2停用3合并
     private Timestamp updDatetime;//更新时间
     private String updUser;//更新人
     private String historyCode;//历史企业编码
     private Short mergeState;//合并处理状态 0未处理1已处理
     
     private Timestamp orgCodeStartDate; //组织机构代码有效期始
     private Timestamp orgCodeEnddDate ; //组织机构代码有效期止
     private Double lastYearSales ; //上年销售额（万元）
     private String regAddress ; //注册地区
    

	private StdCompinfoDetail stdCompinfoDetail;//企业详情
	
	private StdCompgroup stdCompgroup;//集团信息
	
	private DicArea dicArea;//地区信息
	
	private DicCompType dicCompType;//企业注册类型
	
	private long count;//查询总数
	
	@OneToOne(cascade=CascadeType.ALL,fetch=FetchType.EAGER)
	@NotFound(action=NotFoundAction.IGNORE)
    @JoinColumn(name="comp_reg_id")
	public DicCompType getDicCompType() {
		return dicCompType;
	}

	public void setDicCompType(DicCompType dicCompType) {
		this.dicCompType = dicCompType;
	}

	@OneToOne(cascade=CascadeType.ALL,fetch=FetchType.EAGER)
	@NotFound(action=NotFoundAction.IGNORE)
    @JoinColumn(name="area_id")
	public DicArea getDicArea() {
		return dicArea;
	}

	public void setDicArea(DicArea dicArea) {
		this.dicArea = dicArea;
	}

	@OneToOne(cascade=CascadeType.ALL,fetch=FetchType.EAGER)
	@NotFound(action=NotFoundAction.IGNORE)
    @JoinColumn(name="comp_group_id")
    public StdCompgroup getStdCompgroup() {
		return stdCompgroup;
	}

	public void setStdCompgroup(StdCompgroup stdCompgroup) {
		this.stdCompgroup = stdCompgroup;
	}
	

	@OneToOne(cascade=CascadeType.ALL,fetch=FetchType.EAGER)
	@NotFound(action=NotFoundAction.IGNORE)
    @JoinColumn(name="comp_id")
	public StdCompinfoDetail getStdCompinfoDetail() {
		return stdCompinfoDetail;
	}
	
	public void setStdCompinfoDetail(StdCompinfoDetail stdCompinfoDetail) {
		this.stdCompinfoDetail = stdCompinfoDetail;
	}
    // Constructors

    /** default constructor */
    public StdCompinfo() {
    }

	/** minimal constructor */
    public StdCompinfo(String compCode, String compName, Short compType) {
        this.compCode = compCode;
        this.compName = compName;
        this.compType = compType;
    }
    
    /** full constructor */
    public StdCompinfo(String compCode, String compName, String compSpelCode, String compNameEng, String compShortName, String compShortSpelCode, Short compType, String areaId, String compRegId, String orgCode, String compGroupId, String compPhone, String compAddress, Short compClassify, Short status, Timestamp updDatetime, String historyCode, Short mergeState) {
        this.compCode = compCode;
        this.compName = compName;
        this.compSpelCode = compSpelCode;
        this.compNameEng = compNameEng;
        this.compShortName = compShortName;
        this.compShortSpelCode = compShortSpelCode;
        this.compType = compType;
        this.areaId = areaId;
        this.compRegId = compRegId;
        this.orgCode = orgCode;
        this.compGroupId = compGroupId;
        this.compPhone = compPhone;
        this.compAddress = compAddress;
        this.compClassify = compClassify;
        this.status = status;
        this.updDatetime = updDatetime;
        this.historyCode = historyCode;
        this.mergeState = mergeState;
    }

   
    // Property accessors
    @Id
    @Column(name="comp_id",length=36)

    public String getCompId() {
        return this.compId;
    }
    
    public void setCompId(String compId) {
        this.compId = compId;
    }
    
    @Column(name="comp_code", nullable=false, length=100)

    public String getCompCode() {
        return this.compCode;
    }
    
    public void setCompCode(String compCode) {
        this.compCode = compCode;
    }
    
    @Column(name="comp_name", nullable=false, length=512)

    public String getCompName() {
        return this.compName;
    }
    
    public void setCompName(String compName) {
        this.compName = compName;
    }
    
    @Column(name="comp_spel_code", length=128)

    public String getCompSpelCode() {
        return this.compSpelCode;
    }
    
    public void setCompSpelCode(String compSpelCode) {
        this.compSpelCode = compSpelCode;
    }
    
    @Column(name="comp_name_eng", length=512)

    public String getCompNameEng() {
        return this.compNameEng;
    }
    
    public void setCompNameEng(String compNameEng) {
        this.compNameEng = compNameEng;
    }
    
    @Column(name="comp_short_name", length=256)

    public String getCompShortName() {
        return this.compShortName;
    }
    
    public void setCompShortName(String compShortName) {
        this.compShortName = compShortName;
    }
    
    @Column(name="comp_short_spel_code", length=128)

    public String getCompShortSpelCode() {
        return this.compShortSpelCode;
    }
    
    public void setCompShortSpelCode(String compShortSpelCode) {
        this.compShortSpelCode = compShortSpelCode;
    }
    
    @Column(name="comp_type", nullable=false)

    public Short getCompType() {
        return this.compType;
    }
    
    public void setCompType(Short compType) {
        this.compType = compType;
    }
    
    @Column(name="area_id",insertable=false, updatable=false, length=20)

    public String getAreaId() {
        return this.areaId;
    }
    
    public void setAreaId(String areaId) {
        this.areaId = areaId;
    }
    
    @Column(name="comp_reg_id", insertable=false, updatable=false,length=36)

    public String getCompRegId() {
        return this.compRegId;
    }
    
    public void setCompRegId(String compRegId) {
        this.compRegId = compRegId;
    }
    
    @Column(name="org_code", length=20)

    public String getOrgCode() {
        return this.orgCode;
    }
    
    public void setOrgCode(String orgCode) {
        this.orgCode = orgCode;
    }
    
    @Column(name="comp_group_id",insertable=false, updatable=false, length=36)

    public String getCompGroupId() {
        return this.compGroupId;
    }
    
    public void setCompGroupId(String compGroupId) {
        this.compGroupId = compGroupId;
    }
    
    @Column(name="comp_phone", length=20)

    public String getCompPhone() {
        return this.compPhone;
    }
    
    public void setCompPhone(String compPhone) {
        this.compPhone = compPhone;
    }
    
    @Column(name="comp_address", length=1024)

    public String getCompAddress() {
        return this.compAddress;
    }
    
    public void setCompAddress(String compAddress) {
        this.compAddress = compAddress;
    }
    
    @Column(name="comp_classify")

    public Short getCompClassify() {
        return this.compClassify;
    }
    
    public void setCompClassify(Short compClassify) {
        this.compClassify = compClassify;
    }
    
    @Column(name="status")

    public Short getStatus() {
        return this.status;
    }
    
    public void setStatus(Short status) {
        this.status = status;
    }
    
    
    @Column(name="upd_user", length=36)
    
    public String getUpdUser() {
		return updUser;
	}

	public void setUpdUser(String updUser) {
		this.updUser = updUser;
	}

	@Column(name="upd_datetime", length=19)

    public Timestamp getUpdDatetime() {
        return this.updDatetime;
    }
    
    public void setUpdDatetime(Timestamp updDatetime) {
        this.updDatetime = updDatetime;
    }
    
    @Column(name="history_code", length=100)

    public String getHistoryCode() {
        return this.historyCode;
    }
    
    public void setHistoryCode(String historyCode) {
        this.historyCode = historyCode;
    }
    
    @Column(name="merge_state")

    public Short getMergeState() {
        return this.mergeState;
    }
    
    public void setMergeState(Short mergeState) {
        this.mergeState = mergeState;
    }

    @Transient
	public long getCount() {
		return count;
	}

	public void setCount(long count) {
		this.count = count;
	}
	@Column(name = "org_code_start_date")
	public Timestamp getOrgCodeStartDate() {
		return orgCodeStartDate;
	}

	public void setOrgCodeStartDate(Timestamp orgCodeStartDate) {
		this.orgCodeStartDate = orgCodeStartDate;
	}
	@Column(name = "org_code_end_date")
	public Timestamp getOrgCodeEnddDate() {
		return orgCodeEnddDate;
	}

	public void setOrgCodeEnddDate(Timestamp orgCodeEnddDate) {
		this.orgCodeEnddDate = orgCodeEnddDate;
	}
	@Column(name = "last_year_sales")
	public Double getLastYearSales() {
		return lastYearSales;
	}

	public void setLastYearSales(Double lastYearSales) {
		this.lastYearSales = lastYearSales;
	}
	@Column(name = "reg_address")
	public String getRegAddress() {
		return regAddress;
	}

	public void setRegAddress(String regAddress) {
		this.regAddress = regAddress;
	}

	@Transient
	public String getCompClassifyName() {
		if(compClassify != null ){
			compClassifyName = Classify.getName(Integer.valueOf(compClassify.toString()));
		}
		return compClassifyName;
	}

	public void setCompClassifyName(String compClassifyName) {
		this.compClassifyName = compClassifyName;
	}





}